(function () {
    //获取页面传过来的参数
    var url = decodeURI(location.search); //?id="123456"&Name="bicycle";
    var object = {};
    if (url.indexOf("?") != -1)//url中存在问号，也就说有参数。
    {
        var str = url.substr(1);  //得到?后面的字符串
        var strs = str.split("&");  //将得到的参数分隔成数组[id="123456",Name="bicycle"];
        for (var i = 0; i < strs.length; i++) {
            object[strs[i].split("=")[0]] = strs[i].split("=")[1]
        }
    }
    let data = {
            "title": object.title,
            "topn": 10,
            "master_department" : "",
            "slave_department" : "",
            "resolved" : "",
            "satisfied" : "",
            "key_points" : "",
            "time" : ""
        }
    $.ajax({
        url: "/api/bd/caseRecommend",
        data: JSON.stringify(data),
        type: "POST",
        dataType: "json",
        contentType: "contentType: 'application/json;charset=UTF-8',",
        beforeSend: function () {
            $('#loading').modal('show');
        },
        complete: function () {
            $('#loading').modal('hide');
        },
        success: function (res) {
            // data = jQuery.parseJSON(data);  //dataType指明了返回数据为json类型，故不需要再反序列化
            var contentObj = document.getElementsByClassName("content")[0];
            let data = res.data;
            if(data.content.length == 0){
                contentObj.innerHTML = '没有数据';
                $('#expandBtn').parent().hide();
            }else {
                var isHtml = "";
                var arr = data.content;
                for (var i = 0; i < arr.length; i++) {
                    let cid = arr[i].cid == null ? '暂无' : arr[i].cid;
                    isHtml += '<div class="col-sm-12 work-box">';
                    isHtml += '<div class="work-box-top">';
                    isHtml += '<div class="col-sm-12 work-box-top-box">';
                    isHtml += '<div class="col-sm-10"><a class="work-box-a"><span>承办部门：' + arr[i].masterDepartment + '</span></a></div>';
                    isHtml += '<div class="col-sm-10"><a class="work-box-a"><span>关键词：' + arr[i].keyPoints + '</span></a></div>';
                    isHtml += '</div>';
                    isHtml += '<div class="col-sm-12 work-box-top-class">'
                    isHtml += '<div class="col-sm-6"><a style="color: inherit">相似度：'+Number(arr[i].score * 100).toFixed(1) + "%"+'</a></div>'
                    isHtml += '<div class="col-sm-6" ondblclick="parent.telDetail('+cid+','+""+')"><a style="color: inherit">案件编号：'+ cid +'</a></div>'
                    isHtml += '</div>'
                    isHtml += '<div class="col-sm-12 work-box-class"><a style="color: inherit">案件描述：'+ arr[i].title + '</a></div>';
                    isHtml += '<div class="col-sm-12 work-box-buttom">';
                    isHtml += '<div class="col-sm-6">最近办结（解决）时间：' + arr[i].time + '</div>';
                    isHtml += '<div class="col-sm-4"><div class="col-sm-12 entering-pd">处理情况：'+arr[i].resolved+'</div></div>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                };
            }
            contentObj.innerHTML = isHtml;
        }
    });
})();

